#include "SList.h"

test1()                                                //查找所有
{
	SLTNode* plist = NULL;
	SListPushFront(&plist, 1);
	SListPushFront(&plist, 2);
	SListPushFront(&plist, 3);
	SListPushFront(&plist, 4);
	SListPushFront(&plist, 3);
	SListPushFront(&plist, 5);

	SListPrint(plist);

	SLTNode* trm = SLTNFind(plist, 3);
	int i = 1;
	while (trm)
	{
		printf("第%d个trm的地址:%p\n", i++, trm);
		trm = SLTNFind(trm->next, 3);
	}
}

test2()                                               //查找做修改
{
	SLTNode* plist = NULL;
	SListPushFront(&plist, 1);
	SListPushFront(&plist, 2);
	SListPushFront(&plist, 3);
	SListPushFront(&plist, 4);
	SListPushFront(&plist, 3);
	SListPushFront(&plist, 5);

	SListPrint(plist);

	SLTNode* trm = SLTNFind(plist, 3);

	if (trm != NULL)
	{
		trm->data = 0;
	}
	SListPrint(plist);

}

test3()                                                //查找做插入
{
	SLTNode* plist = NULL;
	SListPushFront(&plist, 1);
	SListPushFront(&plist, 2);
	SListPushFront(&plist, 3);
	SListPushFront(&plist, 4);
	SListPushFront(&plist, 3);
	SListPushFront(&plist, 5);

	SListPrint(plist);

	SLTNode* trm = SLTNFind(plist, 5);

	SListInsert(&plist, trm, 10);
	SListPrint(plist);
}
test4()
{
	SLTNode* plist = NULL;
	SListPushFront(&plist, 1);
	SListPushFront(&plist, 2);
	SListPushFront(&plist, 3);
	SListPushFront(&plist, 4);
	SListPushFront(&plist, 3);
	SListPushFront(&plist, 5);

	SListPrint(plist);
	SLTNode* trm = SLTNFind(plist, 5);
	SListInsert(&plist, trm,3);
	SListPrint(plist);
}

test5()
{
	SLTNode* plist = NULL;
	SListPushFront(&plist, 1);
	SListPushFront(&plist, 2);
	SListPushFront(&plist, 3);
	SListPushFront(&plist, 4);
	SListPushFront(&plist, 3);
	SListPushFront(&plist, 5);

	SListPrint(plist);
	SLTNode* trm = SLTNFind(plist, 3);
	SListPop(&plist, trm);
	SListPrint(plist);
}

test6()
{
	SLTNode* plist = NULL;
	SListPushFront(&plist, 1);
	SListPushFront(&plist, 2);
	SListPushFront(&plist, 3);
	SListPushFront(&plist, 4);
	SListPushFront(&plist, 5);

	SListPrint(plist);
	SLTNode* trm = SLTNFind(plist, 3);
	SListPopAfter(trm);
	SListPrint(plist);
}
int main()
{
	test6();
	return 0;
}